#include<iostream>
#include<vector>
using namespace std;

class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums)
    {
        vector<int>::iterator left = nums.begin();
        vector<int>::iterator right = nums.begin();
        int result = 0;
        int bestResult = 0;
        while (right != nums.end())
        {
            result = result + *right;
            while (result >= target)
            {
                if (right - left + 1 < bestResult || bestResult == 0)
                {
                    bestResult = right - left + 1;
                }
                result = result - *left;
                left++;
            }
            right++;
        }
        return bestResult;
    }
};

void test01()
{
    Solution s;
    vector<int>v;
    v.push_back(2);
    v.push_back(3);
    v.push_back(1);
    v.push_back(2);
    v.push_back(4);
    v.push_back(3);

    cout<<s.minSubArrayLen(7, v);
}

int main()
{
    test01();
}
